var e, a = require("../../../@babel/runtime/helpers/interopRequireDefault"), r = require("../../../@babel/runtime/helpers/defineProperty"), i = a(require("../../../@babel/runtime/regenerator")), t = require("../../../@babel/runtime/helpers/asyncToGenerator"), n = a(require("../../../utils/api"));

Page({
    data: {
        list: [ {
            cardname: "复活卡",
            cardNum: 0,
            image: "/profile/images/resurrection-card.png",
            bkimage: "/profile/images/resurrection-card-bk.png",
            desc: "",
            flip: !1
        }, {
            cardname: "跳过卡",
            cardNum: 0,
            image: "/profile/images/skip-card.png",
            bkimage: "/profile/images/skip-card-bk.png",
            desc: "",
            flip: !1
        }, {
            cardname: "延时卡",
            cardNum: 0,
            image: "/profile/images/delay-card.png",
            bkimage: "/profile/images/delay-card-bk.png",
            desc: "",
            flip: !1
        }, {
            cardname: "去错卡",
            cardNum: 0,
            image: "/profile/images/debug-card.png",
            bkimage: "/profile/images/debug-card-bk.png",
            desc: "",
            flip: !1
        }, {
            cardname: "翻倍卡",
            cardNum: 0,
            image: "/profile/images/double-card.png",
            bkimage: "/profile/images/double-card-bk.png",
            desc: "",
            flip: !1
        } ]
    },
    onLoad: (e = t(i.default.mark(function e(a) {
        var r, t, s, c;
        return i.default.wrap(function(e) {
            for (;;) switch (e.prev = e.next) {
              case 0:
                return r = wx.getStorageSync("openid"), e.prev = 1, e.next = 4, n.default.rewardList({
                    openid: r
                });

              case 4:
                t = e.sent, s = t.result.list, (c = this.data.list).forEach(function(e) {
                    s.forEach(function(a) {
                        e.cardname === a.name && (e.cardNum = a.rewardCount, e.desc = a.desc);
                    });
                }), this.setData({
                    list: c
                }), e.next = 14;
                break;

              case 11:
                e.prev = 11, e.t0 = e.catch(1), console.log(e.t0.msg);

              case 14:
              case "end":
                return e.stop();
            }
        }, e, this, [ [ 1, 11 ] ]);
    })), function(a) {
        return e.apply(this, arguments);
    }),
    tapCard: function(e) {
        var a = e.currentTarget.dataset.index, i = "list[" + a + "].flip";
        this.setData(r({}, i, !this.data.list[a].flip));
    }
});